﻿#pragma once
#include <QMap>
#include "ComponentBase.h"
#include "grating_data.h"


class Grating : public ComponentBase
{
	Q_OBJECT

public:
	Grating(QObject *parent);
	~Grating();

	// 组件初始化处理函数
	virtual int ComponentInit() override;
	/*自检接口*/
	virtual bool ComponentCheckSelfState() override;
	/*复位接口*/
	virtual bool ComponentSelfReset() override;

	virtual void ResponseSystemState(int state) override;

	// 命令执行接口
	virtual bool ExcuteCmd(int cmd, const QByteArray& input, QByteArray& output) override;
private:
	int SetDIInfo(const QString& info);

	bool GetGratingAbleState(const QByteArray& input, QByteArray& output);
	bool SetGratingAbleState(const QByteArray& input, QByteArray& output);
	bool GetGratingTrigState(const QByteArray& input, QByteArray& output);
	
	bool SetGratingDisable(const QString& id, QString& msg);

private:
	QMap<QString, GratingInfo> m_info;

	SystemStateType m_systemState = SystemStateType::system_state_stop;
};
